package com.yuou.data.logscollection.server.controller;

import com.yuou.data.common.base.result.Result;
import com.yuou.data.logscollection.server.entity.dto.LogsCollectionDTO;
import com.yuou.data.logscollection.server.service.ILogPushService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ldf
 * @since 2021/4/17.
 */
@Api(tags = "日志收集")
@RestController
@RequestMapping("/log")
public class LogController {

    @Resource
    ILogPushService logPushService;

    @ApiOperation(value = "埋点日志写入-单")
    @PostMapping("/userActionTrack")
    public Result<Void> userActionTrack(@RequestBody @Validated LogsCollectionDTO dto){
        logPushService.push(dto);
        return Result.success("消息-单发送成功!");
    }

    @ApiOperation(value = "埋点日志写入-批量")
    @PostMapping("/userActionTrackBatch")
    public Result<Void> userActionTrackBatch(@RequestBody @Validated List<LogsCollectionDTO> dto){
        logPushService.pushBatch(dto);
        return Result.success("消息-批量发送成功!");
    }

}
